<uieip type="page" value="login" debug="true" timeout="5000"></uieip>
<uieip type="reg" value="console"></uieip>
<!DOCTYPE html>
<html>

<head>
    <uieip type="file" value="inc" src="/yqwin/easyui/include.txt" cache="true" minute="1440"></uieip>
    <uieip type="file" value="css" src="/yqwin/css/yqwin.min" cache="false"></uieip>
    <uieip type="file" value="js" src="/yqwin/src/yqwin.min" cache="false"></uieip>
    <title>FileEdit</title>
</head>

<body style="margin: 0;">    
    <div style="padding:5px 0 0 5px;">
        <h1>FileEdit uitype=18</h1> 
        <input type="text" id="ff" style="width: 240px;" />
        <p></p>
        <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:getData()">getData</a>
        <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:setData()">setData</a>
        <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:disable()">disable</a>
        <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:enable()">enable</a>
        <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:destroy()">destroy</a>
        <h2>DataGrid</h2>
        <table style="width: 100%;">
                <tr>
                    <td style="width:350px;vertical-align: top;">
                        <div class="easyui-panel" title="editMode" style="width:100%;max-width:370px;padding: 5px;">
                            <div id="div_editMode"></div>
                        </div>
                    </td>
                    <td style="width:260px;vertical-align: top;">
                        <div class="easyui-panel" title="editType" style="width:100%;max-width:370px;padding: 5px;">
                            <div id="div_editType"></div>
                        </div>
                    </td>
                    <td style="width:100px;vertical-align: top;">
                        <div class="easyui-panel" title="editModeNo" style="width:100%;max-width:370px;padding: 5px;">
                            <div id="div_editModeNo"></div>
                        </div>
                    </td>
                    <td style="vertical-align: top;">
                    </td>
                </tr>
        </table>
        <a href="#" class="easyui-linkbutton" data-options="" onclick="javascript:reset()">reset</a>
        <p></p>
        <table id="dg" style="width:80%;height:350px;"></table>
        <br/>
        <h2>yqComboGrid</h2>
        <select id="cg" style="width: 300px;"></select>
        <h2>yqTree</h2>
        <ul id="tt" style="width:350px;height:450px;">
    </ul>
    </div>
  
    <script>
        var dbname="yqbase";

        $(function () {
            $("#div_editMode").radiogroup({
                name: 'radio1',
                labelWidth: 340,
                data: [{
                    value: '1',
                    label: '自由编辑1（包含save按钮）,在当前行中编辑',
                }, {
                    value: '2',
                    label: '自由编辑2（包含save按钮），弹出编辑模态窗体'
                }, {
                    value: '3',
                    label: '编辑（不包含save按钮），弹出编辑模态窗体'
                }],
                value: 3,
                dir: 'v'
            });

            $("#div_editType").radiogroup({
                name: 'radio2',
                labelWidth: 270,
                data: [{
                    value: '1',
                    label: '属性编辑模式 editMode=2,3使用',
                }, {
                    value: '2',
                    label: 'form编辑模式 editMode=2,3使用'
                }],
                value: 1,
                dir: 'v'
            });

            $("#div_editModeNo").radiogroup({
                name: 'radio3',
                labelWidth: 70,
                data: [{
                    value: '1',
                    label: '=1',
                }, {
                    value: '2',
                    label: '=2'
                }, {
                    value: '3',
                    label: '=3'
                }],
                value: 1,
                dir: 'v'
            });

            $("#ff").yqTextFilebox({});

            $.yqDbList({ajaxUrl: "_db.html"}, 
                function (data) {     
                    if (data.error == 0) {
                        dbname=data.rows[0].name;
                        dg();
                    }else{
                        alert(data.info);
                    }
                });
        })

        var tData;
        function getData(){
            tData = $("#ff").yqTextFilebox("getData");
            console.log(tData);
        }
        function setData(){
            $("#ff").yqTextFilebox("setData",{
                "type":"image/jpeg",
                "size":234,
                "name":"aaaa.jpge",
                "storage":"storage123",
                "sid":"sid123456"});
        }
        function disable(){
            $("#ff").yqTextFilebox("disable");
        }
        function enable(){
            $("#ff").yqTextFilebox("enable");
        }
        function destroy(){
            $("#ff").yqTextFilebox("destroy");
            console.log(tData);
        }
        function reset() {
            $("#dg").yqDataGrid({
                editMode: $("#div_editMode").radiogroup("getValue"),
                editType: $("#div_editType").radiogroup("getValue"),
                editModeNo: $("#div_editModeNo").radiogroup("getValue")
            });
        }

        function dg(){
            $("#dg").yqDataGrid({
                ajaxUrl: "/_db.html",
                dbname: dbname,
                tbname: "ab_test_file",
                keyId: "sid",
                bindingKeyId: null,
                bindingValue: null,
                pKeyId: null,
                pKeyValue: null,

                addWhere: "",
                order: "createtime desc",

                frozenNum: 2,
                editMode: 3,
                editType: 1,
                editModeW: 650,
                editModeH: 450,
                editModeNo: 1,
                loadData: true,
                isPage: true,

                isEdit: true,
                copy: false,
                add: true,
                upp: true,
                del: true,
                isdel: false, //可注销
                isdelEdit: false, //注销是否可编辑
                move: false, //可移动

                beforeBindingTitle: function (columns, callback) {
                    callback(columns);
                }, //标题绑定前
                afterBindingTitle: function () {          
                     cg();
                }, //标题绑定后
            });
        }

        function cg(){
            $("#cg").yqComboGrid({
                ajaxUrl: "/_db.html", //ajax地址
                dbname: dbname,   //数据库
                tbname: "ab_test_file",       //表
                keyId: "sid",       //关键字段
                bindingKeyId: null,
                bindingValue: null,
                pKeyId: null,
                pKeyValue: null,

                addWhere: "",                   //额外条件
                order: "createtime desc",                     //排序

                panelWidth: 600,
                panelHeight: 280,

                loadData: true,
                editMode: 1,
                editType: 1,
                editModeW: 650,
                editModeH: 450,
                editModeNo: 1,

                isEdit: true,
                isSeek: true,
                displayMember: "name",          //显示字段

                rownumbers: true,                //显示行号
                isPage: true,                   //分页
                pageNo: 1,
                pageSize: 10,
                pageList: [5, 10, 20, 30, 40, 50],

                isEdit: true, //可编辑
                copy: true,
                add: true,
                upp: true,
                del: true,
                isdel: false, //可注销
                isdelEdit: false, //注销是否可编辑
                move: false, //可移动
                editLinks: [],  //显示的链接菜单
                editMenus: [],  //显示在其它中的菜单

                afterBindingTitle: function () {
                    init_tree();
                 }, //标题绑定后
            });
        }

        function init_tree() {
            $('#tt').yqTree({
                ajaxUrl: "/_db.html", //ajax地址
                dbname: dbname,   //数据库
                tbname: "ab_test_file_tree",       //表
                keyId: "sid",       //关键字段
                bindingKeyId: null,
                bindingValue: null,
                pKeyId: "pid",
                pKeyValue: null,

                loadDataType: 2,    //全局加载模式
                displayMember:"name",   
                loadData: true,

                menuType: 1,  //1-顶部菜单，2-右键菜单，3-顶部+右键  其他，无菜单
               
                overflowY: true,
                //width: 180,
                //height: 300,

                editMode: 2,   //1,2-弹出编辑模态窗体 
                editType: 1,
                editModeW: 600, //模态编辑器宽度 格式为 800（数字） 
                editModeH: 450, //模态编辑器高度 格式为 600（数字） 
                editModeNo: -1, //编辑模板
                afterBindingTitle: function () {
                     $('#tt').yqTree("resize",{});
                }, //标题绑定后
            });
        }
    </script>
</body>

</html>